<template>
	<view>
		<u-switch v-model="switchCheck" :active-color="theme.bgColor" @change="switchChange"></u-switch>
	</view>
</template>

<script>
	export default {
		name:'fa-switch',
		props:{
			field:{
				type:String,
				default:''
			},
			value:{
				type:[String,Number],
				default:0
			}
		},
		watch: {
			value:{
				immediate:true,
				handler(newValue, oldValue) {
					this.switchCheck = newValue==1;
				}
			}
		},
		data() {
			return {
				switchCheck:false
			};
		},
		methods:{
			switchChange(e){
				this.$emit('change',{field:this.field,value:e?'1':'0'});
			}
		}
	}
</script>

<style lang="scss">

</style>
